{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'airline': 'CSN', 'id': 'CSN300', 'airplane': 'B77W', 'airport_s3': 'KJFK', 'airport_s4': 'KJFK', 'airport_d3': 'CAN', 'airport_d4': 'ZGGG'}\n",
      "{'airline': 'CSN', 'id': 'CSN3024', 'airplane': 'B734', 'airport_s3': 'TPE', 'airport_s4': 'RCTP', 'airport_d3': 'CGO', 'airport_d4': 'ZHCC'}\n",
      "{'airline': 'CSN', 'id': 'CSN3025', 'airplane': 'A320', 'airport_s3': 'DYG', 'airport_s4': 'ZGDY', 'airport_d3': 'TPE', 'airport_d4': 'RCTP'}\n",
      "{'airline': 'CSN', 'id': 'CSN303', 'airplane': '', 'airport_s3': 'CAN', 'airport_s4': 'ZGGG', 'airport_d3': 'LHR', 'airport_d4': 'EGLL'}\n",
      "{'airline': 'CSN', 'id': 'CSN304', 'airplane': '787', 'airport_s3': 'LHR', 'airport_s4': 'EGLL', 'airport_d3': 'CAN', 'airport_d4': 'ZGGG'}\n",
      "{'airline': 'CSN', 'id': 'CSN3041', 'airplane': 'A333', 'airport_s3': 'SZX', 'airport_s4': 'ZGSZ', 'airport_d3': 'WUH', 'airport_d4': 'ZHHH'}\n",
      "{'airline': 'CSN', 'id': 'CSN3047', 'airplane': 'A321', 'airport_s3': 'CAN', 'airport_s4': 'ZGGG', 'airport_d3': 'KUL', 'airport_d4': 'WMKK'}\n",
      "{'airline': 'CSN', 'id': 'CSN3050', 'airplane': 'E190', 'airport_s3': 'HAN', 'airport_s4': 'VVNB', 'airport_d3': 'CAN', 'airport_d4': 'ZGGG'}\n",
      "{'airline': 'CSN', 'id': 'CSN3054', 'airplane': 'A320', 'airport_s3': 'REP', 'airport_s4': 'VDSR', 'airport_d3': 'CAN', 'airport_d4': 'ZGGG'}\n",
      "{'airline': 'CSN', 'id': 'CSN3061', 'airplane': 'A321', 'airport_s3': 'CAN', 'airport_s4': 'ZGGG', 'airport_d3': 'ICN', 'airport_d4': 'RKSI'}\n",
      "{'airline': 'CSN', 'id': 'CSN3065', 'airplane': 'A321', 'airport_s3': 'CSX', 'airport_s4': 'ZGHA', 'airport_d3': 'ICN', 'airport_d4': 'RKSI'}\n",
      "{'airline': 'CSN', 'id': 'CSN3076', 'airplane': 'B738', 'airport_s3': 'HKG', 'airport_s4': 'VHHH', 'airport_d3': 'WUH', 'airport_d4': 'ZHHH'}\n",
      "{'airline': 'CSN', 'id': 'CSN3078', 'airplane': 'B738', 'airport_s3': 'MNL', 'airport_s4': 'RPLL', 'airport_d3': 'CAN', 'airport_d4': 'ZGGG'}\n",
      "{'airline': 'CSN', 'id': 'CSN3081', 'airplane': 'B734', 'airport_s3': 'CAN', 'airport_s4': 'ZGGG', 'airport_d3': 'BKK', 'airport_d4': 'VTBS'}\n",
      "{'airline': 'CSN', 'id': 'CSN3086', 'airplane': 'B733', 'airport_s3': 'HND', 'airport_s4': 'RJTT', 'airport_d3': 'CAN', 'airport_d4': 'ZGGG'}\n",
      "{'airline': 'CSN', 'id': 'CSN3092', 'airplane': 'B738', 'airport_s3': 'MNL', 'airport_s4': 'RPLL', 'airport_d3': 'CAN', 'airport_d4': 'ZGGG'}\n",
      "{'airline': 'CSN', 'id': 'CSN3097', 'airplane': 'A330', 'airport_s3': 'CAN', 'airport_s4': 'ZGGG', 'airport_d3': 'TPE', 'airport_d4': 'RCTP'}\n",
      "{'airline': 'CSN', 'id': 'CSN3102', 'airplane': 'A330', 'airport_s3': 'PEK', 'airport_s4': 'ZBAA', 'airport_d3': 'CAN', 'airport_d4': 'ZGGG'}\n",
      "{'airline': 'CSN', 'id': 'CSN3103', 'airplane': 'A330', 'airport_s3': 'CAN', 'airport_s4': 'ZGGG', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}\n",
      "{'airline': 'CSN', 'id': 'CSN3112', 'airplane': 'A333', 'airport_s3': 'PEK', 'airport_s4': 'ZBAA', 'airport_d3': 'CAN', 'airport_d4': 'ZGGG'}\n"
     ]
    }
   ],
   "source": [
    "#解析 航班数据\n",
    "\n",
    "import requests\n",
    "from bs4 import BeautifulSoup\n",
    "\n",
    "headers = {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko'}\n",
    "url= 'https://zh.flightaware.com/live/fleet/CSN'\n",
    "f = requests.get(url, headers=headers)\n",
    "soup= BeautifulSoup(f.text, \"lxml\")\n",
    "fleets_rows= soup.select('table[class=\"prettyTable fullWidth\"] > tr')\n",
    "#print(fleets_rows)\n",
    "for row in fleets_rows:\n",
    "    fields= row.select('a')\n",
    "    #print(fields)\n",
    "    if len(fields) == 3:\n",
    "        fleet_id= fields[0].text\n",
    "        airport_s= fields[1].text\n",
    "        airport_d= fields[2].text\n",
    "        airplane= \"\"\n",
    "    elif len(fields) == 4:\n",
    "        fleet_id= fields[0].text\n",
    "        airplane= fields[1].text\n",
    "        airport_s= fields[2].text\n",
    "        airport_d= fields[3].text\n",
    "    \n",
    "    airline= fleet_id[:3]\n",
    "    if len(airport_s)==10 :\n",
    "        airport_s3= airport_s[:3]\n",
    "        airport_s4= airport_s[6:]\n",
    "    else:\n",
    "        airport_s3= airport_s4= airport_s\n",
    "        \n",
    "    if len(airport_d)==10 :\n",
    "        airport_d3= airport_d[:3]\n",
    "        airport_d4= airport_d[6:]\n",
    "    else:\n",
    "        aireport_d3= aireport_d4= aireport_d\n",
    "    \n",
    "    fleet= {\n",
    "                \"airline\": airline,\n",
    "                \"id\" : fleet_id,\n",
    "                \"airplane\" : airplane,\n",
    "                \"airport_s3\" : airport_s3,\n",
    "                \"airport_s4\" : airport_s4,\n",
    "                \"airport_d3\" : airport_d3,\n",
    "                \"airport_d4\" : airport_d4\n",
    "            }\n",
    "    print(fleet)\n",
    "    \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 将以上代码定义为函数方便使用\n",
    "def parse_fleet( url):\n",
    "    headers = {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko'}\n",
    "    f = requests.get(url, headers=headers)\n",
    "    soup= BeautifulSoup(f.text, \"lxml\")\n",
    "    fleets=[]\n",
    "    fleets_rows= soup.select('table[class=\"prettyTable fullWidth\"] > tr')\n",
    "    #print(fleets_rows)\n",
    "    for row in fleets_rows:\n",
    "        try:\n",
    "            fields= row.select('a')\n",
    "            #print(fields)\n",
    "            if len(fields) == 3:\n",
    "                fleet_id= fields[0].text\n",
    "                airport_s= fields[1].text\n",
    "                airport_d= fields[2].text\n",
    "                airplane= \"\"\n",
    "            elif len(fields) == 4:\n",
    "                fleet_id= fields[0].text\n",
    "                airplane= fields[1].text\n",
    "                airport_s= fields[2].text\n",
    "                airport_d= fields[3].text\n",
    "\n",
    "            airline= fleet_id[:3]\n",
    "            if len(airport_s)==10 :\n",
    "                airport_s3= airport_s[:3]\n",
    "                airport_s4= airport_s[6:]\n",
    "            else:\n",
    "                airport_s3= airport_s4= airport_s\n",
    "\n",
    "            if len(airport_d)==10 :\n",
    "                airport_d3= airport_d[:3]\n",
    "                airport_d4= airport_d[6:]\n",
    "            else:\n",
    "                airport_d3= airport_d4= airport_d\n",
    "\n",
    "            fleet= {\n",
    "                        \"airline\": airline,\n",
    "                        \"id\" : fleet_id,\n",
    "                        \"airplane\" : airplane,\n",
    "                        \"airport_s3\" : airport_s3,\n",
    "                        \"airport_s4\" : airport_s4,\n",
    "                        \"airport_d3\" : airport_d3,\n",
    "                        \"airport_d4\" : airport_d4\n",
    "                    }\n",
    "            fleets.append(fleet)\n",
    "        except:\n",
    "            pass\n",
    "    \n",
    "    return fleets\n",
    "    \n",
    "#parse_fleet('https://zh.flightaware.com/live/fleet/CSN')\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "40\n",
      "80\n",
      "120\n",
      "160\n",
      "200\n",
      "240\n"
     ]
    }
   ],
   "source": [
    "# 试一试offset参数\n",
    "for i in range(0,256, 40):\n",
    "    print (i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[{'airline': 'CSN', 'id': 'CSN300', 'airplane': 'B77W', 'airport_s3': 'KJFK', 'airport_s4': 'KJFK', 'airport_d3': 'CAN', 'airport_d4': 'ZGGG'}, {'airline': 'CSN', 'id': 'CSN3024', 'airplane': 'B734', 'airport_s3': 'TPE', 'airport_s4': 'RCTP', 'airport_d3': 'CGO', 'airport_d4': 'ZHCC'}, {'airline': 'CSN', 'id': 'CSN3025', 'airplane': 'A320', 'airport_s3': 'DYG', 'airport_s4': 'ZGDY', 'airport_d3': 'TPE', 'airport_d4': 'RCTP'}, {'airline': 'CSN', 'id': 'CSN303', 'airplane': '', 'airport_s3': 'CAN', 'airport_s4': 'ZGGG', 'airport_d3': 'LHR', 'airport_d4': 'EGLL'}, {'airline': 'CSN', 'id': 'CSN3039', 'airplane': 'B738', 'airport_s3': 'CAN', 'airport_s4': 'ZGGG', 'airport_d3': 'SIN', 'airport_d4': 'WSSS'}, {'airline': 'CSN', 'id': 'CSN304', 'airplane': '787', 'airport_s3': 'LHR', 'airport_s4': 'EGLL', 'airport_d3': 'CAN', 'airport_d4': 'ZGGG'}, {'airline': 'CSN', 'id': 'CSN3041', 'airplane': 'A333', 'airport_s3': 'SZX', 'airport_s4': 'ZGSZ', 'airport_d3': 'WUH', 'airport_d4': 'ZHHH'}, {'airline': 'CSN', 'id': 'CSN3047', 'airplane': 'A321', 'airport_s3': 'CAN', 'airport_s4': 'ZGGG', 'airport_d3': 'KUL', 'airport_d4': 'WMKK'}, {'airline': 'CSN', 'id': 'CSN3050', 'airplane': 'E190', 'airport_s3': 'HAN', 'airport_s4': 'VVNB', 'airport_d3': 'CAN', 'airport_d4': 'ZGGG'}, {'airline': 'CSN', 'id': 'CSN3054', 'airplane': 'A320', 'airport_s3': 'REP', 'airport_s4': 'VDSR', 'airport_d3': 'CAN', 'airport_d4': 'ZGGG'}, {'airline': 'CSN', 'id': 'CSN3061', 'airplane': 'A321', 'airport_s3': 'CAN', 'airport_s4': 'ZGGG', 'airport_d3': 'ICN', 'airport_d4': 'RKSI'}, {'airline': 'CSN', 'id': 'CSN3065', 'airplane': 'A321', 'airport_s3': 'CSX', 'airport_s4': 'ZGHA', 'airport_d3': 'ICN', 'airport_d4': 'RKSI'}, {'airline': 'CSN', 'id': 'CSN3070', 'airplane': 'B738', 'airport_s3': 'SGN', 'airport_s4': 'VVTS', 'airport_d3': 'CAN', 'airport_d4': 'ZGGG'}, {'airline': 'CSN', 'id': 'CSN3076', 'airplane': 'B738', 'airport_s3': 'HKG', 'airport_s4': 'VHHH', 'airport_d3': 'WUH', 'airport_d4': 'ZHHH'}, {'airline': 'CSN', 'id': 'CSN3078', 'airplane': 'B738', 'airport_s3': 'MNL', 'airport_s4': 'RPLL', 'airport_d3': 'CAN', 'airport_d4': 'ZGGG'}, {'airline': 'CSN', 'id': 'CSN3081', 'airplane': 'B734', 'airport_s3': 'CAN', 'airport_s4': 'ZGGG', 'airport_d3': 'BKK', 'airport_d4': 'VTBS'}, {'airline': 'CSN', 'id': 'CSN3086', 'airplane': 'B733', 'airport_s3': 'HND', 'airport_s4': 'RJTT', 'airport_d3': 'CAN', 'airport_d4': 'ZGGG'}, {'airline': 'CSN', 'id': 'CSN3088', 'airplane': 'A333', 'airport_s3': 'TPE', 'airport_s4': 'RCTP', 'airport_d3': 'SZX', 'airport_d4': 'ZGSZ'}, {'airline': 'CSN', 'id': 'CSN3092', 'airplane': 'B738', 'airport_s3': 'MNL', 'airport_s4': 'RPLL', 'airport_d3': 'CAN', 'airport_d4': 'ZGGG'}, {'airline': 'CSN', 'id': 'CSN3102', 'airplane': 'A330', 'airport_s3': 'PEK', 'airport_s4': 'ZBAA', 'airport_d3': 'CAN', 'airport_d4': 'ZGGG'}]\n",
      "[{'airline': 'CSN', 'id': 'CSN326', 'airplane': 'A333', 'airport_s3': 'SYD', 'airport_s4': 'YSSY', 'airport_d3': 'CAN', 'airport_d4': 'ZGGG'}, {'airline': 'CSN', 'id': 'CSN3260', 'airplane': 'A320', 'airport_s3': 'CKG', 'airport_s4': 'ZUCK', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}, {'airline': 'CSN', 'id': 'CSN3262', 'airplane': 'B734', 'airport_s3': 'SHA', 'airport_s4': 'ZSSS', 'airport_d3': 'NNG', 'airport_d4': 'ZGNN'}, {'airline': 'CSN', 'id': 'CSN3263', 'airplane': 'B733', 'airport_s3': 'NKG', 'airport_s4': 'ZSNJ', 'airport_d3': 'CGQ', 'airport_d4': 'ZYCC'}, {'airline': 'CSN', 'id': 'CSN3266', 'airplane': 'B734', 'airport_s3': 'HGH', 'airport_s4': 'ZSHC', 'airport_d3': 'KWL', 'airport_d4': 'ZGKL'}, {'airline': 'CSN', 'id': 'CSN3270', 'airplane': 'A319', 'airport_s3': 'INC', 'airport_s4': 'ZLIC', 'airport_d3': 'CAN', 'airport_d4': 'ZGGG'}, {'airline': 'CSN', 'id': 'CSN3275', 'airplane': 'B734', 'airport_s3': 'XIY', 'airport_s4': 'ZLXY', 'airport_d3': 'XNN', 'airport_d4': 'ZLXN'}, {'airline': 'CSN', 'id': 'CSN3278', 'airplane': 'B738', 'airport_s3': 'PEK', 'airport_s4': 'ZBAA', 'airport_d3': 'NNG', 'airport_d4': 'ZGNN'}, {'airline': 'CSN', 'id': 'CSN3282', 'airplane': 'B734', 'airport_s3': 'PEK', 'airport_s4': 'ZBAA', 'airport_d3': 'KWL', 'airport_d4': 'ZGKL'}, {'airline': 'CSN', 'id': 'CSN3285', 'airplane': 'B734', 'airport_s3': 'NNG', 'airport_s4': 'ZGNN', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}, {'airline': 'CSN', 'id': 'CSN330', 'airplane': 'B788', 'airport_s3': 'CYVR', 'airport_s4': 'CYVR', 'airport_d3': 'CAN', 'airport_d4': 'ZGGG'}, {'airline': 'CSN', 'id': 'CSN3301', 'airplane': 'B734', 'airport_s3': 'CAN', 'airport_s4': 'ZGGG', 'airport_d3': 'TSN', 'airport_d4': 'ZBTJ'}, {'airline': 'CSN', 'id': 'CSN3327', 'airplane': 'E190', 'airport_s3': 'CAN', 'airport_s4': 'ZGGG', 'airport_d3': 'ZHA', 'airport_d4': 'ZGZJ'}, {'airline': 'CSN', 'id': 'CSN3384', 'airplane': 'E190', 'airport_s3': 'NNY', 'airport_s4': 'ZHNY', 'airport_d3': 'CAN', 'airport_d4': 'ZGGG'}, {'airline': 'CSN', 'id': 'CSN340', 'airplane': 'A320', 'airport_s3': 'ICN', 'airport_s4': 'RKSI', 'airport_d3': 'CAN', 'airport_d4': 'ZGGG'}, {'airline': 'CSN', 'id': 'CSN3402', 'airplane': 'B738', 'airport_s3': 'CTU', 'airport_s4': 'ZUUU', 'airport_d3': 'CAN', 'airport_d4': 'ZGGG'}, {'airline': 'CSN', 'id': 'CSN3406', 'airplane': 'B734', 'airport_s3': 'CKG', 'airport_s4': 'ZUCK', 'airport_d3': 'CAN', 'airport_d4': 'ZGGG'}, {'airline': 'CSN', 'id': 'CSN3410', 'airplane': 'A320', 'airport_s3': 'KMG', 'airport_s4': 'ZPPP', 'airport_d3': 'CAN', 'airport_d4': 'ZGGG'}, {'airline': 'CSN', 'id': 'CSN3415', 'airplane': 'A320', 'airport_s3': 'CAN', 'airport_s4': 'ZGGG', 'airport_d3': 'KMG', 'airport_d4': 'ZPPP'}, {'airline': 'CSN', 'id': 'CSN343', 'airplane': 'A333', 'airport_s3': 'CAN', 'airport_s4': 'ZGGG', 'airport_d3': 'MEL', 'airport_d4': 'YMML'}]\n",
      "[{'airline': 'CSN', 'id': 'CSN358', 'airplane': 'A320', 'airport_s3': 'BKK', 'airport_s4': 'VTBS', 'airport_d3': 'CAN', 'airport_d4': 'ZGGG'}, {'airline': 'CSN', 'id': 'CSN3616', 'airplane': 'A321', 'airport_s3': 'HRB', 'airport_s4': 'ZYHB', 'airport_d3': 'CAN', 'airport_d4': 'ZGGG'}, {'airline': 'CSN', 'id': 'CSN3617', 'airplane': 'B734', 'airport_s3': 'SZX', 'airport_s4': 'ZGSZ', 'airport_d3': 'CGO', 'airport_d4': 'ZHCC'}, {'airline': 'CSN', 'id': 'CSN3636', 'airplane': 'E190', 'airport_s3': 'XUZ', 'airport_s4': 'ZSXZ', 'airport_d3': 'CAN', 'airport_d4': 'ZGGG'}, {'airline': 'CSN', 'id': 'CSN3650', 'airplane': 'A319', 'airport_s3': 'FOC', 'airport_s4': 'ZSFZ', 'airport_d3': 'CAN', 'airport_d4': 'ZGGG'}, {'airline': 'CSN', 'id': 'CSN3652', 'airplane': 'B734', 'airport_s3': 'SHA', 'airport_s4': 'ZSSS', 'airport_d3': 'KWE', 'airport_d4': 'ZUGY'}, {'airline': 'CSN', 'id': 'CSN3655', 'airplane': 'B732', 'airport_s3': 'NKG', 'airport_s4': 'ZSNJ', 'airport_d3': 'SHE', 'airport_d4': 'ZYTX'}, {'airline': 'CSN', 'id': 'CSN3657', 'airplane': 'B732', 'airport_s3': 'KWE', 'airport_s4': 'ZUGY', 'airport_d3': 'PVG', 'airport_d4': 'ZSPD'}, {'airline': 'CSN', 'id': 'CSN3669', 'airplane': 'B738', 'airport_s3': 'WUH', 'airport_s4': 'ZHHH', 'airport_d3': 'TAO', 'airport_d4': 'ZSQD'}, {'airline': 'CSN', 'id': 'CSN3676', 'airplane': 'A320', 'airport_s3': 'HZG', 'airport_s4': 'ZLHZ', 'airport_d3': 'SZX', 'airport_d4': 'ZGSZ'}, {'airline': 'CSN', 'id': 'CSN3678', 'airplane': 'A321', 'airport_s3': 'KMG', 'airport_s4': 'ZPPP', 'airport_d3': 'PVG', 'airport_d4': 'ZSPD'}, {'airline': 'CSN', 'id': 'CSN3688', 'airplane': 'B734', 'airport_s3': 'PEK', 'airport_s4': 'ZBAA', 'airport_d3': 'KWE', 'airport_d4': 'ZUGY'}, {'airline': 'CSN', 'id': 'CSN3690', 'airplane': 'B738', 'airport_s3': 'PVG', 'airport_s4': 'ZSPD', 'airport_d3': 'ZUH', 'airport_d4': 'ZGSD'}, {'airline': 'CSN', 'id': 'CSN3691', 'airplane': 'B732', 'airport_s3': 'KWE', 'airport_s4': 'ZUGY', 'airport_d3': 'CAN', 'airport_d4': 'ZGGG'}, {'airline': 'CSN', 'id': 'CSN3702', 'airplane': 'B38M', 'airport_s3': 'TYN', 'airport_s4': 'ZBYN', 'airport_d3': 'CAN', 'airport_d4': 'ZGGG'}, {'airline': 'CSN', 'id': 'CSN3711', 'airplane': 'B738', 'airport_s3': 'CAN', 'airport_s4': 'ZGGG', 'airport_d3': 'TNA', 'airport_d4': 'ZSJN'}, {'airline': 'CSN', 'id': 'CSN3716', 'airplane': 'B738', 'airport_s3': 'TAO', 'airport_s4': 'ZSQD', 'airport_d3': 'CAN', 'airport_d4': 'ZGGG'}, {'airline': 'CSN', 'id': 'CSN3719', 'airplane': 'B738', 'airport_s3': 'CSX', 'airport_s4': 'ZGHA', 'airport_d3': 'HET', 'airport_d4': 'ZBHH'}, {'airline': 'CSN', 'id': 'CSN373', 'airplane': 'A320', 'airport_s3': 'CAN', 'airport_s4': 'ZGGG', 'airport_d3': 'SGN', 'airport_d4': 'VVTS'}, {'airline': 'CSN', 'id': 'CSN3732', 'airplane': 'B738', 'airport_s3': 'PEK', 'airport_s4': 'ZBAA', 'airport_d3': 'ZUH', 'airport_d4': 'ZGSD'}]\n",
      "[{'airline': 'CSN', 'id': 'CSN3908', 'airplane': 'A330', 'airport_s3': 'SHA', 'airport_s4': 'ZSSS', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}, {'airline': 'CSN', 'id': 'CSN3937', 'airplane': 'A320', 'airport_s3': 'CSX', 'airport_s4': 'ZGHA', 'airport_d3': 'TAO', 'airport_d4': 'ZSQD'}, {'airline': 'CSN', 'id': 'CSN3939', 'airplane': 'B734', 'airport_s3': 'HGH', 'airport_s4': 'ZSHC', 'airport_d3': 'CGO', 'airport_d4': 'ZHCC'}, {'airline': 'CSN', 'id': 'CSN394', 'airplane': 'A320', 'airport_s3': 'CAN', 'airport_s4': 'ZGGG', 'airport_d3': 'SYX', 'airport_d4': 'ZJSY'}, {'airline': 'CSN', 'id': 'CSN3940', 'airplane': 'B733', 'airport_s3': 'URC', 'airport_s4': 'ZWWW', 'airport_d3': 'CGO', 'airport_d4': 'ZHCC'}, {'airline': 'CSN', 'id': 'CSN3966', 'airplane': 'A333', 'airport_s3': 'SHA', 'airport_s4': 'ZSSS', 'airport_d3': 'SZX', 'airport_d4': 'ZGSZ'}, {'airline': 'CSN', 'id': 'CSN3967', 'airplane': 'A320', 'airport_s3': 'CSX', 'airport_s4': 'ZGHA', 'airport_d3': 'PVG', 'airport_d4': 'ZSPD'}, {'airline': 'CSN', 'id': 'CSN3972', 'airplane': 'B738', 'airport_s3': 'CGO', 'airport_s4': 'ZHCC', 'airport_d3': 'INC', 'airport_d4': 'ZLIC'}, {'airline': 'CSN', 'id': 'CSN3987', 'airplane': 'B734', 'airport_s3': 'WUH', 'airport_s4': 'ZHHH', 'airport_d3': 'CGQ', 'airport_d4': 'ZYCC'}, {'airline': 'CSN', 'id': 'CSN399', 'airplane': 'B77W', 'airport_s3': 'CAN', 'airport_s4': 'ZGGG', 'airport_d3': 'KJFK', 'airport_d4': 'KJFK'}, {'airline': 'CSN', 'id': 'CSN431', 'airplane': 'B77L', 'airport_s3': 'PVG', 'airport_s4': 'ZSPD', 'airport_d3': 'PANC', 'airport_d4': 'PANC'}, {'airline': 'CSN', 'id': 'CSN434', 'airplane': 'B77L', 'airport_s3': 'KORD', 'airport_s4': 'KORD', 'airport_d3': 'PVG', 'airport_d4': 'ZSPD'}, {'airline': 'CSN', 'id': 'CSN457', 'airplane': 'B77L', 'airport_s3': 'CKG', 'airport_s4': 'ZUCK', 'airport_d3': 'AMS', 'airport_d4': 'EHAM'}, {'airline': 'CSN', 'id': 'CSN463', 'airplane': 'B77L', 'airport_s3': 'PVG', 'airport_s4': 'ZSPD', 'airport_d3': 'FRA', 'airport_d4': 'EDDF'}, {'airline': 'CSN', 'id': 'CSN473', 'airplane': 'B77L', 'airport_s3': 'CAN', 'airport_s4': 'ZGGG', 'airport_d3': 'PANC', 'airport_d4': 'PANC'}, {'airline': 'CSN', 'id': 'CSN478', 'airplane': 'B77L', 'airport_s3': 'KLAX', 'airport_s4': 'KLAX', 'airport_d3': 'CAN', 'airport_d4': 'ZGGG'}, {'airline': 'CSN', 'id': 'CSN6024', 'airplane': 'B738', 'airport_s3': 'URC', 'airport_s4': 'ZWWW', 'airport_d3': 'CAN', 'airport_d4': 'ZGGG'}, {'airline': 'CSN', 'id': 'CSN6063', 'airplane': 'A320', 'airport_s3': 'CAN', 'airport_s4': 'ZGGG', 'airport_d3': 'HKT', 'airport_d4': 'VTSP'}, {'airline': 'CSN', 'id': 'CSN6088', 'airplane': 'A320', 'airport_s3': 'ICN', 'airport_s4': 'RKSI', 'airport_d3': 'MDG', 'airport_d4': 'ZYMD'}, {'airline': 'CSN', 'id': 'CSN6093', 'airplane': 'A320', 'airport_s3': 'SZX', 'airport_s4': 'ZGSZ', 'airport_d3': 'HKT', 'airport_d4': 'VTSP'}]\n",
      "[{'airline': 'CSN', 'id': 'CSN6269', 'airplane': 'A320', 'airport_s3': 'XIY', 'airport_s4': 'ZLXY', 'airport_d3': 'KMG', 'airport_d4': 'ZPPP'}, {'airline': 'CSN', 'id': 'CSN6276', 'airplane': 'A320', 'airport_s3': 'CAN', 'airport_s4': 'ZGGG', 'airport_d3': 'CGQ', 'airport_d4': 'ZYCC'}, {'airline': 'CSN', 'id': 'CSN6277', 'airplane': 'A320', 'airport_s3': 'SJW', 'airport_s4': 'ZBSJ', 'airport_d3': 'DYG', 'airport_d4': 'ZGDY'}, {'airline': 'CSN', 'id': 'CSN628', 'airplane': 'A320', 'airport_s3': 'NRT', 'airport_s4': 'RJAA', 'airport_d3': 'SHE', 'airport_d4': 'ZYTX'}, {'airline': 'CSN', 'id': 'CSN6281', 'airplane': 'A321', 'airport_s3': 'DLC', 'airport_s4': 'ZYTL', 'airport_d3': 'WUH', 'airport_d4': 'ZHHH'}, {'airline': 'CSN', 'id': 'CSN6285', 'airplane': 'A320', 'airport_s3': 'TNA', 'airport_s4': 'ZSJN', 'airport_d3': 'URC', 'airport_d4': 'ZWWW'}, {'airline': 'CSN', 'id': 'CSN6300', 'airplane': 'A321', 'airport_s3': 'SZX', 'airport_s4': 'ZGSZ', 'airport_d3': 'DLC', 'airport_d4': 'ZYTL'}, {'airline': 'CSN', 'id': 'CSN6305', 'airplane': 'B738', 'airport_s3': 'URC', 'airport_s4': 'ZWWW', 'airport_d3': 'XIY', 'airport_d4': 'ZLXY'}, {'airline': 'CSN', 'id': 'CSN6307', 'airplane': 'A320', 'airport_s3': 'CKG', 'airport_s4': 'ZUCK', 'airport_d3': 'URC', 'airport_d4': 'ZWWW'}, {'airline': 'CSN', 'id': 'CSN6309', 'airplane': 'A321', 'airport_s3': 'SHE', 'airport_s4': 'ZYTX', 'airport_d3': 'SZX', 'airport_d4': 'ZGSZ'}, {'airline': 'CSN', 'id': 'CSN6317', 'airplane': 'B734', 'airport_s3': 'WUH', 'airport_s4': 'ZHHH', 'airport_d3': 'HRB', 'airport_d4': 'ZYHB'}, {'airline': 'CSN', 'id': 'CSN632', 'airplane': 'A320', 'airport_s3': 'KIX', 'airport_s4': 'RJBB', 'airport_d3': 'HRB', 'airport_d4': 'ZYHB'}, {'airline': 'CSN', 'id': 'CSN6322', 'airplane': 'A320', 'airport_s3': 'CAN', 'airport_s4': 'ZGGG', 'airport_d3': 'DLC', 'airport_d4': 'ZYTL'}, {'airline': 'CSN', 'id': 'CSN6353', 'airplane': 'B738', 'airport_s3': 'CKG', 'airport_s4': 'ZUCK', 'airport_d3': 'CGO', 'airport_d4': 'ZHCC'}, {'airline': 'CSN', 'id': 'CSN6356', 'airplane': 'B734', 'airport_s3': 'HAK', 'airport_s4': 'ZJHK', 'airport_d3': 'CGO', 'airport_d4': 'ZHCC'}, {'airline': 'CSN', 'id': 'CSN6357', 'airplane': 'A321', 'airport_s3': 'TAO', 'airport_s4': 'ZSQD', 'airport_d3': 'SZX', 'airport_d4': 'ZGSZ'}, {'airline': 'CSN', 'id': 'CSN6377', 'airplane': 'A321', 'airport_s3': 'CGQ', 'airport_s4': 'ZYCC', 'airport_d3': 'CAN', 'airport_d4': 'ZGGG'}, {'airline': 'CSN', 'id': 'CSN6381', 'airplane': 'B738', 'airport_s3': 'KWE', 'airport_s4': 'ZUGY', 'airport_d3': 'HGH', 'airport_d4': 'ZSHC'}, {'airline': 'CSN', 'id': 'CSN6403', 'airplane': 'A320', 'airport_s3': 'CKG', 'airport_s4': 'ZUCK', 'airport_d3': 'KMG', 'airport_d4': 'ZPPP'}, {'airline': 'CSN', 'id': 'CSN6414', 'airplane': 'A321', 'airport_s3': 'XIY', 'airport_s4': 'ZLXY', 'airport_d3': 'DAT', 'airport_d4': 'ZBDT'}]\n",
      "[{'airline': 'CSN', 'id': 'CSN6651', 'airplane': 'A320', 'airport_s3': 'WUH', 'airport_s4': 'ZHHH', 'airport_d3': 'CGQ', 'airport_d4': 'ZYCC'}, {'airline': 'CSN', 'id': 'CSN6655', 'airplane': 'B734', 'airport_s3': 'SWA', 'airport_s4': 'ZGOW', 'airport_d3': 'YIW', 'airport_d4': 'ZSYW'}, {'airline': 'CSN', 'id': 'CSN6658', 'airplane': 'A321', 'airport_s3': 'HEK', 'airport_s4': 'ZYHE', 'airport_d3': 'HRB', 'airport_d4': 'ZYHB'}, {'airline': 'CSN', 'id': 'CSN6661', 'airplane': 'B738', 'airport_s3': 'CGO', 'airport_s4': 'ZHCC', 'airport_d3': 'URC', 'airport_d4': 'ZWWW'}, {'airline': 'CSN', 'id': 'CSN6665', 'airplane': 'A320', 'airport_s3': 'HGH', 'airport_s4': 'ZSHC', 'airport_d3': 'HRB', 'airport_d4': 'ZYHB'}, {'airline': 'CSN', 'id': 'CSN6667', 'airplane': 'A321', 'airport_s3': 'TNA', 'airport_s4': 'ZSJN', 'airport_d3': 'ZUH', 'airport_d4': 'ZGSD'}, {'airline': 'CSN', 'id': 'CSN6674', 'airplane': 'A321', 'airport_s3': 'CTU', 'airport_s4': 'ZUUU', 'airport_d3': 'SHE', 'airport_d4': 'ZYTX'}, {'airline': 'CSN', 'id': 'CSN6693', 'airplane': 'E190', 'airport_s3': 'SHF', 'airport_s4': 'ZWHZ', 'airport_d3': 'CGO', 'airport_d4': 'ZHCC'}, {'airline': 'CSN', 'id': 'CSN6709', 'airplane': 'A320', 'airport_s3': 'XMN', 'airport_s4': 'ZSAM', 'airport_d3': 'DLC', 'airport_d4': 'ZYTL'}, {'airline': 'CSN', 'id': 'CSN6712', 'airplane': 'A320', 'airport_s3': 'PEK', 'airport_s4': 'ZBAA', 'airport_d3': 'SYX', 'airport_d4': 'ZJSY'}, {'airline': 'CSN', 'id': 'CSN6721', 'airplane': 'A320', 'airport_s3': 'YCU', 'airport_s4': 'ZBYC', 'airport_d3': 'HRB', 'airport_d4': 'ZYHB'}, {'airline': 'CSN', 'id': 'CSN6726', 'airplane': 'A320', 'airport_s3': 'CGO', 'airport_s4': 'ZHCC', 'airport_d3': 'HAK', 'airport_d4': 'ZJHK'}, {'airline': 'CSN', 'id': 'CSN674', 'airplane': 'A332', 'airport_s3': 'LHR', 'airport_s4': 'EGLL', 'airport_d3': 'WUH', 'airport_d4': 'ZHHH'}, {'airline': 'CSN', 'id': 'CSN6754', 'airplane': 'A320', 'airport_s3': 'PVG', 'airport_s4': 'ZSPD', 'airport_d3': 'SYX', 'airport_d4': 'ZJSY'}, {'airline': 'CSN', 'id': 'CSN6761', 'airplane': 'A320', 'airport_s3': 'SWA', 'airport_s4': 'ZGOW', 'airport_d3': 'SHE', 'airport_d4': 'ZYTX'}, {'airline': 'CSN', 'id': 'CSN6767', 'airplane': 'A320', 'airport_s3': 'HAK', 'airport_s4': 'ZJHK', 'airport_d3': 'CSX', 'airport_d4': 'ZGHA'}, {'airline': 'CSN', 'id': 'CSN6797', 'airplane': 'B733', 'airport_s3': 'CKG', 'airport_s4': 'ZUCK', 'airport_d3': 'URC', 'airport_d4': 'ZWWW'}, {'airline': 'CSN', 'id': 'CSN6809', 'airplane': 'E190', 'airport_s3': 'URC', 'airport_s4': 'ZWWW', 'airport_d3': 'KHG', 'airport_d4': 'ZWSH'}, {'airline': 'CSN', 'id': 'CSN6815', 'airplane': 'B738', 'airport_s3': 'URC', 'airport_s4': 'ZWWW', 'airport_d3': 'HTN', 'airport_d4': 'ZWTN'}, {'airline': 'CSN', 'id': 'CSN682', 'airplane': 'A321', 'airport_s3': 'ICN', 'airport_s4': 'RKSI', 'airport_d3': 'SHE', 'airport_d4': 'ZYTX'}]\n",
      "[{'airline': 'CSN', 'id': 'CSN6967', 'airplane': 'A320', 'airport_s3': 'SZX', 'airport_s4': 'ZGSZ', 'airport_d3': 'HGH', 'airport_d4': 'ZSHC'}, {'airline': 'CSN', 'id': 'CSN6971', 'airplane': 'B738', 'airport_s3': 'URC', 'airport_s4': 'ZWWW', 'airport_d3': 'NKG', 'airport_d4': 'ZSNJ'}, {'airline': 'CSN', 'id': 'CSN6973', 'airplane': 'B38M', 'airport_s3': 'URC', 'airport_s4': 'ZWWW', 'airport_d3': 'SHA', 'airport_d4': 'ZSSS'}, {'airline': 'CSN', 'id': 'CSN6975', 'airplane': 'B733', 'airport_s3': 'URC', 'airport_s4': 'ZWWW', 'airport_d3': 'PVG', 'airport_d4': 'ZSPD'}, {'airline': 'CSN', 'id': 'CSN6981', 'airplane': 'B738', 'airport_s3': 'URC', 'airport_s4': 'ZWWW', 'airport_d3': 'SHA', 'airport_d4': 'ZSSS'}, {'airline': 'CSN', 'id': 'CSN6989', 'airplane': 'B738', 'airport_s3': 'URC', 'airport_s4': 'ZWWW', 'airport_d3': 'SHA', 'airport_d4': 'ZSSS'}, {'airline': 'CSN', 'id': 'CSN6998', 'airplane': 'B738', 'airport_s3': 'SHA', 'airport_s4': 'ZSSS', 'airport_d3': 'URC', 'airport_d4': 'ZWWW'}, {'airline': 'CSN', 'id': 'CSN8247', 'airplane': 'A321', 'airport_s3': 'DLC', 'airport_s4': 'ZYTL', 'airport_d3': 'TYN', 'airport_d4': 'ZBYN'}, {'airline': 'CSN', 'id': 'CSN8286', 'airplane': 'B738', 'airport_s3': 'CKG', 'airport_s4': 'ZUCK', 'airport_d3': 'ZUH', 'airport_d4': 'ZGSD'}, {'airline': 'CSN', 'id': 'CSN8314', 'airplane': 'A319', 'airport_s3': 'PNH', 'airport_s4': 'VDPP', 'airport_d3': 'CAN', 'airport_d4': 'ZGGG'}, {'airline': 'CSN', 'id': 'CSN8328', 'airplane': 'B738', 'airport_s3': 'CNX', 'airport_s4': 'VTCC', 'airport_d3': 'CAN', 'airport_d4': 'ZGGG'}, {'airline': 'CSN', 'id': 'CSN8384', 'airplane': 'B738', 'airport_s3': 'NRT', 'airport_s4': 'RJAA', 'airport_d3': 'CGO', 'airport_d4': 'ZHCC'}, {'airline': 'CSN', 'id': 'CSN8425', 'airplane': 'A320', 'airport_s3': 'SZX', 'airport_s4': 'ZGSZ', 'airport_d3': 'KIX', 'airport_d4': 'RJBB'}, {'airline': 'CSN', 'id': 'CSN8453', 'airplane': 'A321', 'airport_s3': 'CAN', 'airport_s4': 'ZGGG', 'airport_d3': 'PEN', 'airport_d4': 'WMKP'}, {'airline': 'CSN', 'id': 'CSN8465', 'airplane': 'A320', 'airport_s3': 'SZX', 'airport_s4': 'ZGSZ', 'airport_d3': 'SGN', 'airport_d4': 'VVTS'}, {'airline': 'CSN', 'id': 'CSN8468', 'airplane': 'A320', 'airport_s3': 'PNH', 'airport_s4': 'VDPP', 'airport_d3': 'SZX', 'airport_d4': 'ZGSZ'}, {'airline': 'CSN', 'id': 'CSN8476', 'airplane': 'B734', 'airport_s3': 'CXR', 'airport_s4': 'VVCR', 'airport_d3': 'CAN', 'airport_d4': 'ZGGG'}, {'airline': 'CSN', 'id': 'CSN8513', 'airplane': 'A320', 'airport_s3': 'HET', 'airport_s4': 'ZBHH', 'airport_d3': 'HAK', 'airport_d4': 'ZJHK'}, {'airline': 'CSN', 'id': 'CSN8533', 'airplane': 'B734', 'airport_s3': 'CGO', 'airport_s4': 'ZHCC', 'airport_d3': 'KRY', 'airport_d4': 'ZWKM'}, {'airline': 'CSN', 'id': 'CSN8545', 'airplane': 'B734', 'airport_s3': 'KWE', 'airport_s4': 'ZUGY', 'airport_d3': 'URC', 'airport_d4': 'ZWWW'}]\n",
      "[{'airline': 'CES', 'id': 'CES2005', 'airplane': 'A320', 'airport_s3': 'TAO', 'airport_s4': 'ZSQD', 'airport_d3': 'NGO', 'airport_d4': 'RJGG'}, {'airline': 'CES', 'id': 'CES2014', 'airplane': 'A320', 'airport_s3': 'TPE', 'airport_s4': 'RCTP', 'airport_d3': 'LHW', 'airport_d4': 'ZLAN'}, {'airline': 'CES', 'id': 'CES2018', 'airplane': 'A320', 'airport_s3': 'ICN', 'airport_s4': 'RKSI', 'airport_d3': 'WEH', 'airport_d4': 'ZSWH'}, {'airline': 'CES', 'id': 'CES2028', 'airplane': 'A332', 'airport_s3': 'TPE', 'airport_s4': 'RCTP', 'airport_d3': 'KMG', 'airport_d4': 'ZPPP'}, {'airline': 'CES', 'id': 'CES2034', 'airplane': 'A321', 'airport_s3': 'ICN', 'airport_s4': 'RKSI', 'airport_d3': 'TAO', 'airport_d4': 'ZSQD'}, {'airline': 'CES', 'id': 'CES2048', 'airplane': 'A320', 'airport_s3': 'TPE', 'airport_s4': 'RCTP', 'airport_d3': 'KHN', 'airport_d4': 'ZSCN'}, {'airline': 'CES', 'id': 'CES205', 'airplane': 'A320', 'airport_s3': 'PVG', 'airport_s4': 'ZSPD', 'airport_d3': 'CNX', 'airport_d4': 'VTCC'}, {'airline': 'CES', 'id': 'CES207', 'airplane': 'B773', 'airport_s3': 'PVG', 'airport_s4': 'ZSPD', 'airport_d3': 'CYYZ', 'airport_d4': 'CYYZ'}, {'airline': 'CES', 'id': 'CES208', 'airplane': 'B77W', 'airport_s3': 'CYYZ', 'airport_s4': 'CYYZ', 'airport_d3': 'PVG', 'airport_d4': 'ZSPD'}, {'airline': 'CES', 'id': 'CES2094', 'airplane': 'A319', 'airport_s3': 'YUS', 'airport_s4': 'ZLYS', 'airport_d3': 'CTU', 'airport_d4': 'ZUUU'}, {'airline': 'CES', 'id': 'CES2096', 'airplane': 'A320', 'airport_s3': 'TPE', 'airport_s4': 'RCTP', 'airport_d3': 'TXN', 'airport_d4': 'ZSTX'}, {'airline': 'CES', 'id': 'CES2098', 'airplane': 'A320', 'airport_s3': 'KIX', 'airport_s4': 'RJBB', 'airport_d3': 'NGB', 'airport_d4': 'ZSNB'}, {'airline': 'CES', 'id': 'CES2108', 'airplane': 'A321', 'airport_s3': 'PEK', 'airport_s4': 'ZBAA', 'airport_d3': 'XIY', 'airport_d4': 'ZLXY'}, {'airline': 'CES', 'id': 'CES2141', 'airplane': 'A320', 'airport_s3': 'DSN', 'airport_s4': 'ZBDS', 'airport_d3': 'CGQ', 'airport_d4': 'ZYCC'}, {'airline': 'CES', 'id': 'CES2144', 'airplane': 'B735', 'airport_s3': 'KMG', 'airport_s4': 'ZPPP', 'airport_d3': 'TYN', 'airport_d4': 'ZBYN'}, {'airline': 'CES', 'id': 'CES215', 'airplane': 'A332', 'airport_s3': 'NKG', 'airport_s4': 'ZSNJ', 'airport_d3': 'CYVR', 'airport_d4': 'CYVR'}, {'airline': 'CES', 'id': 'CES2154', 'airplane': 'A320', 'airport_s3': 'SHA', 'airport_s4': 'ZSSS', 'airport_d3': 'XIY', 'airport_d4': 'ZLXY'}, {'airline': 'CES', 'id': 'CES2156', 'airplane': 'A320', 'airport_s3': 'SHA', 'airport_s4': 'ZSSS', 'airport_d3': 'XIY', 'airport_d4': 'ZLXY'}, {'airline': 'CES', 'id': 'CES2157', 'airplane': 'A321', 'airport_s3': 'XIY', 'airport_s4': 'ZLXY', 'airport_d3': 'SHA', 'airport_d4': 'ZSSS'}, {'airline': 'CES', 'id': 'CES2165', 'airplane': 'A320', 'airport_s3': 'JGN', 'airport_s4': 'ZLJQ', 'airport_d3': 'XIY', 'airport_d4': 'ZLXY'}]\n",
      "[{'airline': 'CES', 'id': 'CES2335', 'airplane': 'A319', 'airport_s3': 'XIY', 'airport_s4': 'ZLXY', 'airport_d3': 'LXA', 'airport_d4': 'ZULS'}, {'airline': 'CES', 'id': 'CES2392', 'airplane': 'B738', 'airport_s3': 'XIY', 'airport_s4': 'ZLXY', 'airport_d3': 'WNZ', 'airport_d4': 'ZSWZ'}, {'airline': 'CES', 'id': 'CES2409', 'airplane': 'B732', 'airport_s3': 'SHA', 'airport_s4': 'ZSSS', 'airport_d3': 'TYN', 'airport_d4': 'ZBYN'}, {'airline': 'CES', 'id': 'CES2446', 'airplane': 'A320', 'airport_s3': 'LHW', 'airport_s4': 'ZLAN', 'airport_d3': 'HGH', 'airport_d4': 'ZSHC'}, {'airline': 'CES', 'id': 'CES2453', 'airplane': 'B738', 'airport_s3': 'ENH', 'airport_s4': 'ZHES', 'airport_d3': 'WUH', 'airport_d4': 'ZHHH'}, {'airline': 'CES', 'id': 'CES2461', 'airplane': 'B735', 'airport_s3': 'XIY', 'airport_s4': 'ZLXY', 'airport_d3': 'URC', 'airport_d4': 'ZWWW'}, {'airline': 'CES', 'id': 'CES2468', 'airplane': 'A320', 'airport_s3': 'JGD', 'airport_s4': 'ZYJD', 'airport_d3': 'HRB', 'airport_d4': 'ZYHB'}, {'airline': 'CES', 'id': 'CES2469', 'airplane': 'B738', 'airport_s3': 'SHA', 'airport_s4': 'ZSSS', 'airport_d3': 'WUH', 'airport_d4': 'ZHHH'}, {'airline': 'CES', 'id': 'CES2473', 'airplane': 'B735', 'airport_s3': 'WUH', 'airport_s4': 'ZHHH', 'airport_d3': 'NGB', 'airport_d4': 'ZSNB'}, {'airline': 'CES', 'id': 'CES2476', 'airplane': 'B738', 'airport_s3': 'HYN', 'airport_s4': 'ZSLQ', 'airport_d3': 'CAN', 'airport_d4': 'ZGGG'}, {'airline': 'CES', 'id': 'CES2485', 'airplane': 'B735', 'airport_s3': 'WUH', 'airport_s4': 'ZHHH', 'airport_d3': 'KMG', 'airport_d4': 'ZPPP'}, {'airline': 'CES', 'id': 'CES2508', 'airplane': 'B738', 'airport_s3': 'SHA', 'airport_s4': 'ZSSS', 'airport_d3': 'WUH', 'airport_d4': 'ZHHH'}, {'airline': 'CES', 'id': 'CES2518', 'airplane': 'B738', 'airport_s3': 'DLC', 'airport_s4': 'ZYTL', 'airport_d3': 'TAO', 'airport_d4': 'ZSQD'}, {'airline': 'CES', 'id': 'CES2521', 'airplane': 'B732', 'airport_s3': 'WUH', 'airport_s4': 'ZHHH', 'airport_d3': 'SHA', 'airport_d4': 'ZSSS'}, {'airline': 'CES', 'id': 'CES2546', 'airplane': 'B735', 'airport_s3': 'SHE', 'airport_s4': 'ZYTX', 'airport_d3': 'YNZ', 'airport_d4': 'ZSYN'}, {'airline': 'CES', 'id': 'CES258', 'airplane': 'A332', 'airport_s3': 'XIY', 'airport_s4': 'ZLXY', 'airport_d3': 'PVG', 'airport_d4': 'ZSPD'}, {'airline': 'CES', 'id': 'CES2581', 'airplane': 'B735', 'airport_s3': 'KMG', 'airport_s4': 'ZPPP', 'airport_d3': 'DAD', 'airport_d4': 'VVDN'}, {'airline': 'CES', 'id': 'CES2613', 'airplane': 'B738', 'airport_s3': 'WUH', 'airport_s4': 'ZHHH', 'airport_d3': 'INC', 'airport_d4': 'ZLIC'}, {'airline': 'CES', 'id': 'CES2622', 'airplane': 'B735', 'airport_s3': 'DAT', 'airport_s4': 'ZBDT', 'airport_d3': 'WUH', 'airport_d4': 'ZHHH'}, {'airline': 'CES', 'id': 'CES2702', 'airplane': 'A321', 'airport_s3': 'HRB', 'airport_s4': 'ZYHB', 'airport_d3': 'TAO', 'airport_d4': 'ZSQD'}]\n",
      "[{'airline': 'CES', 'id': 'CES2902', 'airplane': 'A321', 'airport_s3': 'HKG', 'airport_s4': 'VHHH', 'airport_d3': 'WUX', 'airport_d4': 'ZSWX'}, {'airline': 'CES', 'id': 'CES2906', 'airplane': 'A321', 'airport_s3': 'CTU', 'airport_s4': 'ZUUU', 'airport_d3': 'WUX', 'airport_d4': 'ZSWX'}, {'airline': 'CES', 'id': 'CES291', 'airplane': 'A320', 'airport_s3': 'XIY', 'airport_s4': 'ZLXY', 'airport_d3': 'PVG', 'airport_d4': 'ZSPD'}, {'airline': 'CES', 'id': 'CES292', 'airplane': 'A320', 'airport_s3': 'PVG', 'airport_s4': 'ZSPD', 'airport_d3': 'XIY', 'airport_d4': 'ZLXY'}, {'airline': 'CES', 'id': 'CES2951', 'airplane': 'A320', 'airport_s3': 'ZUH', 'airport_s4': 'ZGSD', 'airport_d3': 'NKG', 'airport_d4': 'ZSNJ'}, {'airline': 'CES', 'id': 'CES2964', 'airplane': 'A320', 'airport_s3': 'HET', 'airport_s4': 'ZBHH', 'airport_d3': 'WUX', 'airport_d4': 'ZSWX'}, {'airline': 'CES', 'id': 'CES2969', 'airplane': 'A320', 'airport_s3': 'CKG', 'airport_s4': 'ZUCK', 'airport_d3': 'CZX', 'airport_d4': 'ZSCG'}, {'airline': 'CES', 'id': 'CES2975', 'airplane': 'A320', 'airport_s3': 'WUX', 'airport_s4': 'ZSWX', 'airport_d3': 'KMG', 'airport_d4': 'ZPPP'}, {'airline': 'CES', 'id': 'CES2983', 'airplane': 'A320', 'airport_s3': 'CZX', 'airport_s4': 'ZSCG', 'airport_d3': 'XIY', 'airport_d4': 'ZLXY'}, {'airline': 'CES', 'id': 'CES5007', 'airplane': 'A333', 'airport_s3': 'PVG', 'airport_s4': 'ZSPD', 'airport_d3': 'TPE', 'airport_d4': 'RCTP'}, {'airline': 'CES', 'id': 'CES5012', 'airplane': '', 'airport_s3': 'TPE', 'airport_s4': 'RCTP', 'airport_d3': 'TYN', 'airport_d4': 'ZBYN'}, {'airline': 'CES', 'id': 'CES5022', 'airplane': 'A320', 'airport_s3': 'ICN', 'airport_s4': 'RKSI', 'airport_d3': 'TAO', 'airport_d4': 'ZSQD'}, {'airline': 'CES', 'id': 'CES503', 'airplane': 'A320', 'airport_s3': 'PVG', 'airport_s4': 'ZSPD', 'airport_d3': 'HKG', 'airport_d4': 'VHHH'}, {'airline': 'CES', 'id': 'CES5033', 'airplane': 'A321', 'airport_s3': 'PVG', 'airport_s4': 'ZSPD', 'airport_d3': 'ICN', 'airport_d4': 'RKSI'}, {'airline': 'CES', 'id': 'CES5042', 'airplane': 'A320', 'airport_s3': 'ICN', 'airport_s4': 'RKSI', 'airport_d3': 'PVG', 'airport_d4': 'ZSPD'}, {'airline': 'CES', 'id': 'CES5060', 'airplane': 'A333', 'airport_s3': 'CJU', 'airport_s4': 'RKPC', 'airport_d3': 'PVG', 'airport_d4': 'ZSPD'}, {'airline': 'CES', 'id': 'CES507', 'airplane': 'A321', 'airport_s3': 'PVG', 'airport_s4': 'ZSPD', 'airport_d3': 'HKG', 'airport_d4': 'VHHH'}, {'airline': 'CES', 'id': 'CES5077', 'airplane': 'A320', 'airport_s3': 'HFE', 'airport_s4': 'ZSOF', 'airport_d3': 'KMG', 'airport_d4': 'ZPPP'}, {'airline': 'CES', 'id': 'CES5109', 'airplane': 'A333', 'airport_s3': 'SHA', 'airport_s4': 'ZSSS', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}, {'airline': 'CES', 'id': 'CES5110', 'airplane': 'A333', 'airport_s3': 'PEK', 'airport_s4': 'ZBAA', 'airport_d3': 'SHA', 'airport_d4': 'ZSSS'}]\n",
      "[{'airline': 'CES', 'id': 'CES5275', 'airplane': 'A321', 'airport_s3': 'SHA', 'airport_s4': 'ZSSS', 'airport_d3': 'INC', 'airport_d4': 'ZLIC'}, {'airline': 'CES', 'id': 'CES5288', 'airplane': 'A320', 'airport_s3': 'CAN', 'airport_s4': 'ZGGG', 'airport_d3': 'HFE', 'airport_d4': 'ZSOF'}, {'airline': 'CES', 'id': 'CES5292', 'airplane': 'B738', 'airport_s3': 'TYN', 'airport_s4': 'ZBYN', 'airport_d3': 'KMG', 'airport_d4': 'ZPPP'}, {'airline': 'CES', 'id': 'CES5295', 'airplane': 'B738', 'airport_s3': 'TYN', 'airport_s4': 'ZBYN', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}, {'airline': 'CES', 'id': 'CES530', 'airplane': 'A320', 'airport_s3': 'NGO', 'airport_s4': 'RJGG', 'airport_d3': 'PVG', 'airport_d4': 'ZSPD'}, {'airline': 'CES', 'id': 'CES5301', 'airplane': 'B732', 'airport_s3': 'SHA', 'airport_s4': 'ZSSS', 'airport_d3': 'CAN', 'airport_d4': 'ZGGG'}, {'airline': 'CES', 'id': 'CES5327', 'airplane': 'A320', 'airport_s3': 'KHN', 'airport_s4': 'ZSCN', 'airport_d3': 'KMG', 'airport_d4': 'ZPPP'}, {'airline': 'CES', 'id': 'CES5336', 'airplane': 'A321', 'airport_s3': 'SZX', 'airport_s4': 'ZGSZ', 'airport_d3': 'SHA', 'airport_d4': 'ZSSS'}, {'airline': 'CES', 'id': 'CES5338', 'airplane': 'A321', 'airport_s3': 'SZX', 'airport_s4': 'ZGSZ', 'airport_d3': 'SHA', 'airport_d4': 'ZSSS'}, {'airline': 'CES', 'id': 'CES5341', 'airplane': 'A320', 'airport_s3': 'SHA', 'airport_s4': 'ZSSS', 'airport_d3': 'SZX', 'airport_d4': 'ZGSZ'}, {'airline': 'CES', 'id': 'CES5342', 'airplane': 'A332', 'airport_s3': 'SZX', 'airport_s4': 'ZGSZ', 'airport_d3': 'PVG', 'airport_d4': 'ZSPD'}, {'airline': 'CES', 'id': 'CES5377', 'airplane': 'A320', 'airport_s3': 'PVG', 'airport_s4': 'ZSPD', 'airport_d3': 'SYX', 'airport_d4': 'ZJSY'}, {'airline': 'CES', 'id': 'CES5379', 'airplane': 'A320', 'airport_s3': 'WNZ', 'airport_s4': 'ZSWZ', 'airport_d3': 'LZH', 'airport_d4': 'ZGZH'}, {'airline': 'CES', 'id': 'CES538', 'airplane': 'A333', 'airport_s3': 'HND', 'airport_s4': 'RJTT', 'airport_d3': 'SHA', 'airport_d4': 'ZSSS'}, {'airline': 'CES', 'id': 'CES5393', 'airplane': 'A321', 'airport_s3': 'SHA', 'airport_s4': 'ZSSS', 'airport_d3': 'CAN', 'airport_d4': 'ZGGG'}, {'airline': 'CES', 'id': 'CES5407', 'airplane': 'A321', 'airport_s3': 'PVG', 'airport_s4': 'ZSPD', 'airport_d3': 'CTU', 'airport_d4': 'ZUUU'}, {'airline': 'CES', 'id': 'CES5408', 'airplane': 'A321', 'airport_s3': 'CTU', 'airport_s4': 'ZUUU', 'airport_d3': 'SHA', 'airport_d4': 'ZSSS'}, {'airline': 'CES', 'id': 'CES5419', 'airplane': 'A320', 'airport_s3': 'PVG', 'airport_s4': 'ZSPD', 'airport_d3': 'CTU', 'airport_d4': 'ZUUU'}, {'airline': 'CES', 'id': 'CES5425', 'airplane': 'A321', 'airport_s3': 'PVG', 'airport_s4': 'ZSPD', 'airport_d3': 'CKG', 'airport_d4': 'ZUCK'}, {'airline': 'CES', 'id': 'CES5427', 'airplane': 'B735', 'airport_s3': 'SHA', 'airport_s4': 'ZSSS', 'airport_d3': 'CKG', 'airport_d4': 'ZUCK'}]\n",
      "[{'airline': 'CES', 'id': 'CES5602', 'airplane': 'A320', 'airport_s3': 'PVG', 'airport_s4': 'ZSPD', 'airport_d3': 'ZHA', 'airport_d4': 'ZGZJ'}, {'airline': 'CES', 'id': 'CES5604', 'airplane': 'A320', 'airport_s3': 'SHE', 'airport_s4': 'ZYTX', 'airport_d3': 'PVG', 'airport_d4': 'ZSPD'}, {'airline': 'CES', 'id': 'CES5608', 'airplane': 'A320', 'airport_s3': 'HIA', 'airport_s4': 'ZSSH', 'airport_d3': 'PVG', 'airport_d4': 'ZSPD'}, {'airline': 'CES', 'id': 'CES5613', 'airplane': 'A320', 'airport_s3': 'HRB', 'airport_s4': 'ZYHB', 'airport_d3': 'HEK', 'airport_d4': 'ZYHE'}, {'airline': 'CES', 'id': 'CES562', 'airplane': 'A332', 'airport_s3': 'SYD', 'airport_s4': 'YSSY', 'airport_d3': 'PVG', 'airport_d4': 'ZSPD'}, {'airline': 'CES', 'id': 'CES564', 'airplane': 'A333', 'airport_s3': 'PVG', 'airport_s4': 'ZSPD', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}, {'airline': 'CES', 'id': 'CES5643', 'airplane': 'A320', 'airport_s3': 'SHA', 'airport_s4': 'ZSSS', 'airport_d3': 'TSN', 'airport_d4': 'ZBTJ'}, {'airline': 'CES', 'id': 'CES5647', 'airplane': 'A320', 'airport_s3': 'SHA', 'airport_s4': 'ZSSS', 'airport_d3': 'XMN', 'airport_d4': 'ZSAM'}, {'airline': 'CES', 'id': 'CES5649', 'airplane': 'A320', 'airport_s3': 'NGB', 'airport_s4': 'ZSNB', 'airport_d3': 'ZUH', 'airport_d4': 'ZGSD'}, {'airline': 'CES', 'id': 'CES5653', 'airplane': 'A320', 'airport_s3': 'HFE', 'airport_s4': 'ZSOF', 'airport_d3': 'YNT', 'airport_d4': 'ZSYT'}, {'airline': 'CES', 'id': 'CES5659', 'airplane': 'A320', 'airport_s3': 'KHN', 'airport_s4': 'ZSCN', 'airport_d3': 'HUZ', 'airport_d4': 'ZGHZ'}, {'airline': 'CES', 'id': 'CES5669', 'airplane': 'A320', 'airport_s3': 'PVG', 'airport_s4': 'ZSPD', 'airport_d3': 'DLC', 'airport_d4': 'ZYTL'}, {'airline': 'CES', 'id': 'CES567', 'airplane': 'A332', 'airport_s3': 'PVG', 'airport_s4': 'ZSPD', 'airport_d3': 'SIN', 'airport_d4': 'WSSS'}, {'airline': 'CES', 'id': 'CES5672', 'airplane': 'A320', 'airport_s3': 'YNJ', 'airport_s4': 'ZYYJ', 'airport_d3': 'TAO', 'airport_d4': 'ZSQD'}, {'airline': 'CES', 'id': 'CES5681', 'airplane': 'B738', 'airport_s3': 'CSX', 'airport_s4': 'ZGHA', 'airport_d3': 'HAK', 'airport_d4': 'ZJHK'}, {'airline': 'CES', 'id': 'CES569', 'airplane': 'B773', 'airport_s3': 'PVG', 'airport_s4': 'ZSPD', 'airport_d3': 'CDG', 'airport_d4': 'LFPG'}, {'airline': 'CES', 'id': 'CES5693', 'airplane': 'A321', 'airport_s3': 'PEK', 'airport_s4': 'ZBAA', 'airport_d3': 'LYA', 'airport_d4': 'ZHLY'}, {'airline': 'CES', 'id': 'CES5695', 'airplane': 'A321', 'airport_s3': 'PEK', 'airport_s4': 'ZBAA', 'airport_d3': 'LYA', 'airport_d4': 'ZHLY'}, {'airline': 'CES', 'id': 'CES5698', 'airplane': 'A321', 'airport_s3': 'CGQ', 'airport_s4': 'ZYCC', 'airport_d3': 'PVG', 'airport_d4': 'ZSPD'}, {'airline': 'CES', 'id': 'CES5699', 'airplane': 'A320', 'airport_s3': 'PVG', 'airport_s4': 'ZSPD', 'airport_d3': 'URC', 'airport_d4': 'ZWWW'}]\n",
      "[{'airline': 'CES', 'id': 'CES586', 'airplane': 'B77W', 'airport_s3': 'KLAX', 'airport_s4': 'KLAX', 'airport_d3': 'PVG', 'airport_d4': 'ZSPD'}, {'airline': 'CES', 'id': 'CES5863', 'airplane': '', 'airport_s3': 'CKG', 'airport_s4': 'ZUCK', 'airport_d3': 'YNT', 'airport_d4': 'ZSYT'}, {'airline': 'CES', 'id': 'CES5865', 'airplane': '', 'airport_s3': 'ZAT', 'airport_s4': 'ZPZT', 'airport_d3': 'CKG', 'airport_d4': 'ZUCK'}, {'airline': 'CES', 'id': 'CES587', 'airplane': 'B773', 'airport_s3': 'PVG', 'airport_s4': 'ZSPD', 'airport_d3': 'KJFK', 'airport_d4': 'KJFK'}, {'airline': 'CES', 'id': 'CES5876', 'airplane': 'B738', 'airport_s3': 'WUH', 'airport_s4': 'ZHHH', 'airport_d3': 'KMG', 'airport_d4': 'ZPPP'}, {'airline': 'CES', 'id': 'CES588', 'airplane': 'B77W', 'airport_s3': 'KJFK', 'airport_s4': 'KJFK', 'airport_d3': 'PVG', 'airport_d4': 'ZSPD'}, {'airline': 'CES', 'id': 'CES5880', 'airplane': 'B735', 'airport_s3': 'WNZ', 'airport_s4': 'ZSWZ', 'airport_d3': 'KMG', 'airport_d4': 'ZPPP'}, {'airline': 'CES', 'id': 'CES589', 'airplane': 'B773', 'airport_s3': 'PVG', 'airport_s4': 'ZSPD', 'airport_d3': 'KSFO', 'airport_d4': 'KSFO'}, {'airline': 'CES', 'id': 'CES590', 'airplane': 'B773', 'airport_s3': 'KSFO', 'airport_s4': 'KSFO', 'airport_d3': 'PVG', 'airport_d4': 'ZSPD'}, {'airline': 'CES', 'id': 'CES591', 'airplane': 'A333', 'airport_s3': 'PVG', 'airport_s4': 'ZSPD', 'airport_d3': 'SVO', 'airport_d4': 'UUEE'}, {'airline': 'CES', 'id': 'CES5951', 'airplane': '', 'airport_s3': 'KMG', 'airport_s4': 'ZPPP', 'airport_d3': 'TCZ', 'airport_d4': 'ZUTC'}, {'airline': 'CES', 'id': 'CES709', 'airplane': 'A332', 'airport_s3': 'PVG', 'airport_s4': 'ZSPD', 'airport_d3': 'MAD', 'airport_d4': 'LEMD'}, {'airline': 'CES', 'id': 'CES716', 'airplane': 'A332', 'airport_s3': 'BNE', 'airport_s4': 'YBBN', 'airport_d3': 'PVG', 'airport_d4': 'ZSPD'}, {'airline': 'CES', 'id': 'CES718', 'airplane': 'B77W', 'airport_s3': 'KORD', 'airport_s4': 'KORD', 'airport_d3': 'PVG', 'airport_d4': 'ZSPD'}, {'airline': 'CES', 'id': 'CES719', 'airplane': 'A320', 'airport_s3': 'PVG', 'airport_s4': 'ZSPD', 'airport_d3': 'NGO', 'airport_d4': 'RJGG'}, {'airline': 'CES', 'id': 'CES722', 'airplane': 'A333', 'airport_s3': 'HKG', 'airport_s4': 'VHHH', 'airport_d3': 'SHA', 'airport_d4': 'ZSSS'}, {'airline': 'CES', 'id': 'CES728', 'airplane': 'A332', 'airport_s3': 'SYD', 'airport_s4': 'YSSY', 'airport_d3': 'NKG', 'airport_d4': 'ZSNJ'}, {'airline': 'CES', 'id': 'CES738', 'airplane': 'A332', 'airport_s3': 'MEL', 'airport_s4': 'YMML', 'airport_d3': 'PVG', 'airport_d4': 'ZSPD'}, {'airline': 'CES', 'id': 'CES747', 'airplane': 'B732', 'airport_s3': 'PVG', 'airport_s4': 'ZSPD', 'airport_d3': 'KIX', 'airport_d4': 'RJBB'}, {'airline': 'CES', 'id': 'CES750', 'airplane': 'A332', 'airport_s3': 'SYD', 'airport_s4': 'YSSY', 'airport_d3': 'WUH', 'airport_d4': 'ZHHH'}]\n",
      "[{'airline': 'CCA', 'id': 'CCA102', 'airplane': 'A321', 'airport_s3': 'HKG', 'airport_s4': 'VHHH', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}, {'airline': 'CCA', 'id': 'CCA104', 'airplane': 'B732', 'airport_s3': 'HKG', 'airport_s4': 'VHHH', 'airport_d3': 'TSN', 'airport_d4': 'ZBTJ'}, {'airline': 'CCA', 'id': 'CCA105', 'airplane': 'B738', 'airport_s3': 'DLC', 'airport_s4': 'ZYTL', 'airport_d3': 'HKG', 'airport_d4': 'VHHH'}, {'airline': 'CCA', 'id': 'CCA108', 'airplane': 'A321', 'airport_s3': 'HKG', 'airport_s4': 'VHHH', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}, {'airline': 'CCA', 'id': 'CCA109', 'airplane': 'A333', 'airport_s3': 'PEK', 'airport_s4': 'ZBAA', 'airport_d3': 'HKG', 'airport_d4': 'VHHH'}, {'airline': 'CCA', 'id': 'CCA1112', 'airplane': 'B38M', 'airport_s3': 'HET', 'airport_s4': 'ZBHH', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}, {'airline': 'CCA', 'id': 'CCA1122', 'airplane': 'B738', 'airport_s3': 'BAV', 'airport_s4': 'ZBOW', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}, {'airline': 'CCA', 'id': 'CCA118', 'airplane': 'B738', 'airport_s3': 'HKG', 'airport_s4': 'VHHH', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}, {'airline': 'CCA', 'id': 'CCA1210', 'airplane': '73K', 'airport_s3': 'XIY', 'airport_s4': 'ZLXY', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}, {'airline': 'CCA', 'id': 'CCA1215', 'airplane': 'A321', 'airport_s3': 'XIY', 'airport_s4': 'ZLXY', 'airport_d3': 'PVG', 'airport_d4': 'ZSPD'}, {'airline': 'CCA', 'id': 'CCA1219', 'airplane': 'A320', 'airport_s3': 'PEK', 'airport_s4': 'ZBAA', 'airport_d3': 'INC', 'airport_d4': 'ZLIC'}, {'airline': 'CCA', 'id': 'CCA1223', 'airplane': 'A320', 'airport_s3': 'PEK', 'airport_s4': 'ZBAA', 'airport_d3': 'XIY', 'airport_d4': 'ZLXY'}, {'airline': 'CCA', 'id': 'CCA1233', 'airplane': 'B738', 'airport_s3': 'PEK', 'airport_s4': 'ZBAA', 'airport_d3': 'KRY', 'airport_d4': 'ZWKM'}, {'airline': 'CCA', 'id': 'CCA124', 'airplane': 'A320', 'airport_s3': 'ICN', 'airport_s4': 'RKSI', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}, {'airline': 'CCA', 'id': 'CCA1253', 'airplane': 'B38M', 'airport_s3': 'PEK', 'airport_s4': 'ZBAA', 'airport_d3': 'URC', 'airport_d4': 'ZWWW'}, {'airline': 'CCA', 'id': 'CCA1257', 'airplane': 'A321', 'airport_s3': 'INC', 'airport_s4': 'ZLIC', 'airport_d3': 'PVG', 'airport_d4': 'ZSPD'}, {'airline': 'CCA', 'id': 'CCA1265', 'airplane': 'B738', 'airport_s3': 'PEK', 'airport_s4': 'ZBAA', 'airport_d3': 'XNN', 'airport_d4': 'ZLXN'}, {'airline': 'CCA', 'id': 'CCA1270', 'airplane': 'B732', 'airport_s3': 'KRL', 'airport_s4': 'ZWKL', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}, {'airline': 'CCA', 'id': 'CCA1271', 'airplane': 'B732', 'airport_s3': 'PEK', 'airport_s4': 'ZBAA', 'airport_d3': 'LHW', 'airport_d4': 'ZLAN'}, {'airline': 'CCA', 'id': 'CCA1274', 'airplane': 'B732', 'airport_s3': 'LHW', 'airport_s4': 'ZLAN', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}]\n",
      "[{'airline': 'CCA', 'id': 'CCA1404', 'airplane': 'A330', 'airport_s3': 'KMG', 'airport_s4': 'ZPPP', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}, {'airline': 'CCA', 'id': 'CCA1406', 'airplane': 'B77W', 'airport_s3': 'CTU', 'airport_s4': 'ZUUU', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}, {'airline': 'CCA', 'id': 'CCA1418', 'airplane': 'B732', 'airport_s3': 'KWE', 'airport_s4': 'ZUGY', 'airport_d3': 'TSN', 'airport_d4': 'ZBTJ'}, {'airline': 'CCA', 'id': 'CCA1420', 'airplane': 'A319', 'airport_s3': 'DLU', 'airport_s4': 'ZPDL', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}, {'airline': 'CCA', 'id': 'CCA1424', 'airplane': 'B732', 'airport_s3': 'LPF', 'airport_s4': 'LPF', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}, {'airline': 'CCA', 'id': 'CCA1428', 'airplane': 'B737', 'airport_s3': 'CTU', 'airport_s4': 'ZUUU', 'airport_d3': 'TSN', 'airport_d4': 'ZBTJ'}, {'airline': 'CCA', 'id': 'CCA1430', 'airplane': 'B738', 'airport_s3': 'CKG', 'airport_s4': 'ZUCK', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}, {'airline': 'CCA', 'id': 'CCA1432', 'airplane': 'A330', 'airport_s3': 'CKG', 'airport_s4': 'ZUCK', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}, {'airline': 'CCA', 'id': 'CCA1452', 'airplane': 'B738', 'airport_s3': 'MIG', 'airport_s4': 'ZUMY', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}, {'airline': 'CCA', 'id': 'CCA1458', 'airplane': 'B732', 'airport_s3': 'GYS', 'airport_s4': 'ZUGU', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}, {'airline': 'CCA', 'id': 'CCA1462', 'airplane': 'B38M', 'airport_s3': 'KWE', 'airport_s4': 'ZUGY', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}, {'airline': 'CCA', 'id': 'CCA1470', 'airplane': 'A319', 'airport_s3': 'LJG', 'airport_s4': 'ZPLJ', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}, {'airline': 'CCA', 'id': 'CCA1471', 'airplane': 'A320', 'airport_s3': 'PEK', 'airport_s4': 'ZBAA', 'airport_d3': 'KWL', 'airport_d4': 'ZGKL'}, {'airline': 'CCA', 'id': 'CCA1480', 'airplane': 'A320', 'airport_s3': 'ZUH', 'airport_s4': 'ZGSD', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}, {'airline': 'CCA', 'id': 'CCA1485', 'airplane': 'A321', 'airport_s3': 'PEK', 'airport_s4': 'ZBAA', 'airport_d3': 'NNG', 'airport_d4': 'ZGNN'}, {'airline': 'CCA', 'id': 'CCA1487', 'airplane': 'B737', 'airport_s3': 'DAX', 'airport_s4': 'ZUDX', 'airport_d3': 'KMG', 'airport_d4': 'ZPPP'}, {'airline': 'CCA', 'id': 'CCA150', 'airplane': 'A320', 'airport_s3': 'TPE', 'airport_s4': 'RCTP', 'airport_d3': 'HGH', 'airport_d4': 'ZSHC'}, {'airline': 'CCA', 'id': 'CCA1502', 'airplane': 'B732', 'airport_s3': 'SHA', 'airport_s4': 'ZSSS', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}, {'airline': 'CCA', 'id': 'CCA1506', 'airplane': 'B737', 'airport_s3': 'FOC', 'airport_s4': 'ZSFZ', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}, {'airline': 'CCA', 'id': 'CCA1511', 'airplane': 'B738', 'airport_s3': 'PEK', 'airport_s4': 'ZBAA', 'airport_d3': 'KHN', 'airport_d4': 'ZSCN'}]\n",
      "[{'airline': 'CCA', 'id': 'CCA170', 'airplane': 'B732', 'airport_s3': 'CTS', 'airport_s4': 'RJCC', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}, {'airline': 'CCA', 'id': 'CCA1705', 'airplane': 'A320', 'airport_s3': 'HGH', 'airport_s4': 'ZSHC', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}, {'airline': 'CCA', 'id': 'CCA1742', 'airplane': 'A321', 'airport_s3': 'CTU', 'airport_s4': 'ZUUU', 'airport_d3': 'HGH', 'airport_d4': 'ZSHC'}, {'airline': 'CCA', 'id': 'CCA1743', 'airplane': 'A320', 'airport_s3': 'XIY', 'airport_s4': 'ZLXY', 'airport_d3': 'KRY', 'airport_d4': 'ZWKM'}, {'airline': 'CCA', 'id': 'CCA1752', 'airplane': 'A320', 'airport_s3': 'KMG', 'airport_s4': 'ZPPP', 'airport_d3': 'HGH', 'airport_d4': 'ZSHC'}, {'airline': 'CCA', 'id': 'CCA1760', 'airplane': 'A319', 'airport_s3': 'CKG', 'airport_s4': 'ZUCK', 'airport_d3': 'HGH', 'airport_d4': 'ZSHC'}, {'airline': 'CCA', 'id': 'CCA1778', 'airplane': 'A321', 'airport_s3': 'NNG', 'airport_s4': 'ZGNN', 'airport_d3': 'HGH', 'airport_d4': 'ZSHC'}, {'airline': 'CCA', 'id': 'CCA178', 'airplane': 'A332', 'airport_s3': 'MEL', 'airport_s4': 'YMML', 'airport_d3': 'PVG', 'airport_d4': 'ZSPD'}, {'airline': 'CCA', 'id': 'CCA1781', 'airplane': 'A320', 'airport_s3': 'YCU', 'airport_s4': 'ZBYC', 'airport_d3': 'URC', 'airport_d4': 'ZWWW'}, {'airline': 'CCA', 'id': 'CCA1784', 'airplane': 'B738', 'airport_s3': 'ZHA', 'airport_s4': 'ZGZJ', 'airport_d3': 'HGH', 'airport_d4': 'ZSHC'}, {'airline': 'CCA', 'id': 'CCA1788', 'airplane': 'A320', 'airport_s3': 'HRB', 'airport_s4': 'ZYHB', 'airport_d3': 'WEH', 'airport_d4': 'ZSWH'}, {'airline': 'CCA', 'id': 'CCA1790', 'airplane': 'A319', 'airport_s3': 'DQA', 'airport_s4': 'ZYDQ', 'airport_d3': 'YNT', 'airport_d4': 'ZSYT'}, {'airline': 'CCA', 'id': 'CCA1792', 'airplane': 'A319', 'airport_s3': 'HLD', 'airport_s4': 'ZBLA', 'airport_d3': 'UCB', 'airport_d4': 'ZBWL'}, {'airline': 'CCA', 'id': 'CCA1806', 'airplane': 'B738', 'airport_s3': 'JGS', 'airport_s4': 'ZSJA', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}, {'airline': 'CCA', 'id': 'CCA1818', 'airplane': 'B738', 'airport_s3': 'NKG', 'airport_s4': 'ZSNJ', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}, {'airline': 'CCA', 'id': 'CCA182', 'airplane': 'A333', 'airport_s3': 'HND', 'airport_s4': 'RJTT', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}, {'airline': 'CCA', 'id': 'CCA1828', 'airplane': 'B738', 'airport_s3': 'WEH', 'airport_s4': 'ZSWH', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}, {'airline': 'CCA', 'id': 'CCA1833', 'airplane': 'B738', 'airport_s3': 'PEK', 'airport_s4': 'ZBAA', 'airport_d3': 'XMN', 'airport_d4': 'ZSAM'}, {'airline': 'CCA', 'id': 'CCA1837', 'airplane': 'A333', 'airport_s3': 'SHA', 'airport_s4': 'ZSSS', 'airport_d3': 'CAN', 'airport_d4': 'ZGGG'}, {'airline': 'CCA', 'id': 'CCA1840', 'airplane': 'B738', 'airport_s3': 'NGB', 'airport_s4': 'ZSNB', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}]\n",
      "[{'airline': 'CCA', 'id': 'CCA1986', 'airplane': 'A321', 'airport_s3': 'CGQ', 'airport_s4': 'ZYCC', 'airport_d3': 'PVG', 'airport_d4': 'ZSPD'}, {'airline': 'CCA', 'id': 'CCA403', 'airplane': 'A320', 'airport_s3': 'CTU', 'airport_s4': 'ZUUU', 'airport_d3': 'SIN', 'airport_d4': 'WSSS'}, {'airline': 'CCA', 'id': 'CCA4032', 'airplane': 'A320', 'airport_s3': 'KRY', 'airport_s4': 'ZWKM', 'airport_d3': 'CTU', 'airport_d4': 'ZUUU'}, {'airline': 'CCA', 'id': 'CCA4037', 'airplane': 'A319', 'airport_s3': 'CTU', 'airport_s4': 'ZUUU', 'airport_d3': 'HTN', 'airport_d4': 'ZWTN'}, {'airline': 'CCA', 'id': 'CCA406', 'airplane': 'A321', 'airport_s3': 'NGO', 'airport_s4': 'RJGG', 'airport_d3': 'PVG', 'airport_d4': 'ZSPD'}, {'airline': 'CCA', 'id': 'CCA407', 'airplane': 'A319', 'airport_s3': 'LXA', 'airport_s4': 'ZULS', 'airport_d3': 'KTM', 'airport_d4': 'VNKT'}, {'airline': 'CCA', 'id': 'CCA4112', 'airplane': 'A319', 'airport_s3': 'CTU', 'airport_s4': 'ZUUU', 'airport_d3': 'LXA', 'airport_d4': 'ZULS'}, {'airline': 'CCA', 'id': 'CCA4114', 'airplane': 'A333', 'airport_s3': 'PEK', 'airport_s4': 'ZBAA', 'airport_d3': 'CTU', 'airport_d4': 'ZUUU'}, {'airline': 'CCA', 'id': 'CCA4124', 'airplane': 'B738', 'airport_s3': 'XMN', 'airport_s4': 'ZSAM', 'airport_d3': 'CKG', 'airport_d4': 'ZUCK'}, {'airline': 'CCA', 'id': 'CCA4130', 'airplane': 'A330', 'airport_s3': 'PEK', 'airport_s4': 'ZBAA', 'airport_d3': 'CKG', 'airport_d4': 'ZUCK'}, {'airline': 'CCA', 'id': 'CCA4152', 'airplane': 'A320', 'airport_s3': 'URC', 'airport_s4': 'ZWWW', 'airport_d3': 'CTU', 'airport_d4': 'ZUUU'}, {'airline': 'CCA', 'id': 'CCA4162', 'airplane': 'A320', 'airport_s3': 'PEK', 'airport_s4': 'ZBAA', 'airport_d3': 'KWE', 'airport_d4': 'ZUGY'}, {'airline': 'CCA', 'id': 'CCA4172', 'airplane': 'A320', 'airport_s3': 'PEK', 'airport_s4': 'ZBAA', 'airport_d3': 'KMG', 'airport_d4': 'ZPPP'}, {'airline': 'CCA', 'id': 'CCA4176', 'airplane': 'A320', 'airport_s3': 'SHE', 'airport_s4': 'ZYTX', 'airport_d3': 'KMG', 'airport_d4': 'ZPPP'}, {'airline': 'CCA', 'id': 'CCA4178', 'airplane': 'A321', 'airport_s3': 'HRB', 'airport_s4': 'ZYHB', 'airport_d3': 'CTU', 'airport_d4': 'ZUUU'}, {'airline': 'CCA', 'id': 'CCA4183', 'airplane': 'A319', 'airport_s3': 'CTU', 'airport_s4': 'ZUUU', 'airport_d3': 'YCU', 'airport_d4': 'ZBYC'}, {'airline': 'CCA', 'id': 'CCA4186', 'airplane': 'A321', 'airport_s3': 'SHE', 'airport_s4': 'ZYTX', 'airport_d3': 'CTU', 'airport_d4': 'ZUUU'}, {'airline': 'CCA', 'id': 'CCA4188', 'airplane': 'A321', 'airport_s3': 'TSN', 'airport_s4': 'ZBTJ', 'airport_d3': 'CTU', 'airport_d4': 'ZUUU'}, {'airline': 'CCA', 'id': 'CCA4190', 'airplane': 'A321', 'airport_s3': 'CGQ', 'airport_s4': 'ZYCC', 'airport_d3': 'CTU', 'airport_d4': 'ZUUU'}, {'airline': 'CCA', 'id': 'CCA4197', 'airplane': 'A321', 'airport_s3': 'CTU', 'airport_s4': 'ZUUU', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}]\n",
      "[{'airline': 'CCA', 'id': 'CCA4520', 'airplane': 'A330', 'airport_s3': 'HGH', 'airport_s4': 'ZSHC', 'airport_d3': 'CTU', 'airport_d4': 'ZUUU'}, {'airline': 'CCA', 'id': 'CCA4530', 'airplane': 'A321', 'airport_s3': 'NGB', 'airport_s4': 'ZSNB', 'airport_d3': 'CTU', 'airport_d4': 'ZUUU'}, {'airline': 'CCA', 'id': 'CCA4544', 'airplane': 'B738', 'airport_s3': 'SHA', 'airport_s4': 'ZSSS', 'airport_d3': 'CKG', 'airport_d4': 'ZUCK'}, {'airline': 'CCA', 'id': 'CCA4550', 'airplane': 'B737', 'airport_s3': 'NGB', 'airport_s4': 'ZSNB', 'airport_d3': 'CKG', 'airport_d4': 'ZUCK'}, {'airline': 'CCA', 'id': 'CCA4552', 'airplane': 'B737', 'airport_s3': 'DLU', 'airport_s4': 'ZPDL', 'airport_d3': 'CKG', 'airport_d4': 'ZUCK'}, {'airline': 'CCA', 'id': 'CCA4554', 'airplane': 'B738', 'airport_s3': 'HGH', 'airport_s4': 'ZSHC', 'airport_d3': 'CKG', 'airport_d4': 'ZUCK'}, {'airline': 'CCA', 'id': 'CCA4562', 'airplane': 'B738', 'airport_s3': 'KHN', 'airport_s4': 'ZSCN', 'airport_d3': 'CKG', 'airport_d4': 'ZUCK'}, {'airline': 'CCA', 'id': 'CCA4568', 'airplane': 'B737', 'airport_s3': 'CGQ', 'airport_s4': 'ZYCC', 'airport_d3': 'HIA', 'airport_d4': 'ZSSH'}, {'airline': 'CCA', 'id': 'CCA4575', 'airplane': 'B738', 'airport_s3': 'CKG', 'airport_s4': 'ZUCK', 'airport_d3': 'AKU', 'airport_d4': 'ZWAK'}, {'airline': 'CCA', 'id': 'CCA4594', 'airplane': 'B738', 'airport_s3': 'CAN', 'airport_s4': 'ZGGG', 'airport_d3': 'YCU', 'airport_d4': 'ZBYC'}, {'airline': 'CCA', 'id': 'CCA461', 'airplane': 'A320', 'airport_s3': 'CTU', 'airport_s4': 'ZUUU', 'airport_d3': 'KIX', 'airport_d4': 'RJBB'}, {'airline': 'CCA', 'id': 'CCA817', 'airplane': 'B773', 'airport_s3': 'PEK', 'airport_s4': 'ZBAA', 'airport_d3': 'KIAD', 'airport_d4': 'KIAD'}, {'airline': 'CCA', 'id': 'CCA818', 'airplane': 'B77W', 'airport_s3': 'KIAD', 'airport_s4': 'KIAD', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}, {'airline': 'CCA', 'id': 'CCA819', 'airplane': 'B773', 'airport_s3': 'PEK', 'airport_s4': 'ZBAA', 'airport_d3': 'KEWR', 'airport_d4': 'KEWR'}, {'airline': 'CCA', 'id': 'CCA8203', 'airplane': 'A320', 'airport_s3': 'WUH', 'airport_s4': 'ZHHH', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}, {'airline': 'CCA', 'id': 'CCA8206', 'airplane': 'A320', 'airport_s3': 'PEK', 'airport_s4': 'ZBAA', 'airport_d3': 'WUH', 'airport_d4': 'ZHHH'}, {'airline': 'CCA', 'id': 'CCA8234', 'airplane': 'A320', 'airport_s3': 'SZX', 'airport_s4': 'ZGSZ', 'airport_d3': 'WUH', 'airport_d4': 'ZHHH'}, {'airline': 'CCA', 'id': 'CCA8248', 'airplane': 'A320', 'airport_s3': 'SHE', 'airport_s4': 'ZYTX', 'airport_d3': 'WUH', 'airport_d4': 'ZHHH'}, {'airline': 'CCA', 'id': 'CCA8279', 'airplane': 'B738', 'airport_s3': 'TSN', 'airport_s4': 'ZBTJ', 'airport_d3': 'TYN', 'airport_d4': 'ZBYN'}, {'airline': 'CCA', 'id': 'CCA8292', 'airplane': 'B737', 'airport_s3': 'INC', 'airport_s4': 'ZLIC', 'airport_d3': 'TSN', 'airport_d4': 'ZBTJ'}]\n",
      "[{'airline': 'CCA', 'id': 'CCA938', 'airplane': 'B773', 'airport_s3': 'LHR', 'airport_s4': 'EGLL', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}, {'airline': 'CCA', 'id': 'CCA940', 'airplane': 'B77W', 'airport_s3': 'FCO', 'airport_s4': 'LIRF', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}, {'airline': 'CCA', 'id': 'CCA952', 'airplane': 'B732', 'airport_s3': 'NRT', 'airport_s4': 'RJAA', 'airport_d3': 'DLC', 'airport_d4': 'ZYTL'}, {'airline': 'CCA', 'id': 'CCA967', 'airplane': 'A332', 'airport_s3': 'PVG', 'airport_s4': 'ZSPD', 'airport_d3': 'MXP', 'airport_d4': 'LIMC'}, {'airline': 'CCA', 'id': 'CCA976', 'airplane': 'B789', 'airport_s3': 'SIN', 'airport_s4': 'WSSS', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}, {'airline': 'CCA', 'id': 'CCA981', 'airplane': 'B748', 'airport_s3': 'PEK', 'airport_s4': 'ZBAA', 'airport_d3': 'KJFK', 'airport_d4': 'KJFK'}, {'airline': 'CCA', 'id': 'CCA982', 'airplane': 'B748', 'airport_s3': 'KJFK', 'airport_s4': 'KJFK', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}, {'airline': 'CCA', 'id': 'CCA985', 'airplane': 'B738', 'airport_s3': 'CKG', 'airport_s4': 'ZUCK', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}, {'airline': 'CCA', 'id': 'CCA986', 'airplane': 'B748', 'airport_s3': 'KSFO', 'airport_s4': 'KSFO', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}, {'airline': 'CCA', 'id': 'CCA988', 'airplane': 'B77W', 'airport_s3': 'KLAX', 'airport_s4': 'KLAX', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}, {'airline': 'CCA', 'id': 'CCA992', 'airplane': 'B77W', 'airport_s3': 'CYVR', 'airport_s4': 'CYVR', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}]\n"
     ]
    }
   ],
   "source": [
    "# 获取每个航空公司航班数据\n",
    "airlines={\"CSN\": 270, \"CES\":226, \"CCA\":212}\n",
    "for name, count in airlines.items():\n",
    "    for offset in range(0, count, 40):\n",
    "        # url: http://flightaware.com/live/fleet/CSN?;offset=0;order=ident;sort=ASC\n",
    "        url= \"http://flightaware.com/live/fleet/\"+name+\"?;offset=\"+str(offset)+\";order=ident;sort=ASC\"\n",
    "        fleets= parse_fleet(url)\n",
    "        print(fleets)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[{'airline': 'CCA', 'id': 'CCA938', 'airplane': 'B773', 'airport_s3': 'LHR', 'airport_s4': 'EGLL', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}]\n"
     ]
    }
   ],
   "source": [
    "# 存储到数据库中\n",
    "fleets=[{'airline': 'CCA', 'id': 'CCA938', 'airplane': 'B773', 'airport_s3': 'LHR', 'airport_s4': 'EGLL', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}]\n",
    "print(fleets)\n",
    "\n",
    "import mysql.connector\n",
    "\n",
    "cnx = mysql.connector.connect(user='flightdata', password='flightdata',\n",
    "                              host='127.0.0.1',\n",
    "                              database='flightdata')\n",
    "cursor = cnx.cursor()\n",
    "cursor.execute(\"create table if not exists fleet(id varchar(50) primary key, airline varchar(10), \\\n",
    "               airplane varchar(10),  airport_s3 varchar(10) ,airport_s4 varchar(10) , \\\n",
    "              airport_d3 varchar(10) ,airport_d4 varchar(10));\")\n",
    "add_fleet = \"INSERT INTO fleet \\\n",
    "              (id, airline, airplane, airport_s3,airport_s4, airport_d3,airport_d4) \\\n",
    "              VALUES (%s,%s,%s,%s,%s,%s,%s)\"\n",
    "for f in fleets:\n",
    "    #print(f['id'])\n",
    "    cursor.execute(add_fleet, (f['id'], f['airline'],f['airplane'],f['airport_s3'],f['airport_s4'], \n",
    "                               f['airport_d3'],f['airport_d4']))\n",
    "    \n",
    "cnx.commit()\n",
    "\n",
    "cursor.close()\n",
    "cnx.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 函数\n",
    "\n",
    "def save_fleet(fleets):\n",
    "    cnx = mysql.connector.connect(user='flightdata', password='flightdata',\n",
    "                              host='127.0.0.1',\n",
    "                              database='flightdata')\n",
    "    cursor = cnx.cursor()\n",
    "    cursor.execute(\"create table if not exists fleet(id varchar(50) primary key, airline varchar(10), \\\n",
    "                   airplane varchar(10),  airport_s3 varchar(10) ,airport_s4 varchar(10) , \\\n",
    "                  airport_d3 varchar(10) ,airport_d4 varchar(10));\")\n",
    "    add_fleet = \"INSERT ignore INTO fleet  \\\n",
    "                  (id, airline, airplane, airport_s3,airport_s4, airport_d3,airport_d4) \\\n",
    "                  VALUES (%s,%s,%s,%s,%s,%s,%s)\"\n",
    "    for f in fleets:\n",
    "        #print(f['id'])\n",
    "        cursor.execute(add_fleet, (f['id'], f['airline'],f['airplane'],f['airport_s3'],f['airport_s4'], \n",
    "                                   f['airport_d3'],f['airport_d4']))\n",
    "\n",
    "    cnx.commit()\n",
    "\n",
    "    cursor.close()\n",
    "    cnx.close()\n",
    "    \n",
    "fleets=[{'airline': 'CCA', 'id': 'CCA938', 'airplane': 'B773', 'airport_s3': 'LHR', 'airport_s4': 'EGLL', 'airport_d3': 'PEK', 'airport_d4': 'ZBAA'}]\n",
    "save_fleet(fleets)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'requests' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-2-b3d102c466c2>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m      4\u001b[0m         \u001b[1;31m# url: http://flightaware.com/live/fleet/CSN?;offset=0;order=ident;sort=ASC\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      5\u001b[0m         \u001b[0murl\u001b[0m\u001b[1;33m=\u001b[0m \u001b[1;34m\"http://flightaware.com/live/fleet/\"\u001b[0m\u001b[1;33m+\u001b[0m\u001b[0mname\u001b[0m\u001b[1;33m+\u001b[0m\u001b[1;34m\"?;offset=\"\u001b[0m\u001b[1;33m+\u001b[0m\u001b[0mstr\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0moffset\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m+\u001b[0m\u001b[1;34m\";order=ident;sort=ASC\"\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 6\u001b[1;33m         \u001b[0mfleets\u001b[0m\u001b[1;33m=\u001b[0m \u001b[0mparse_fleet\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0murl\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      7\u001b[0m         \u001b[0msave_fleet\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mfleets\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32m<ipython-input-1-81cd48408a1d>\u001b[0m in \u001b[0;36mparse_fleet\u001b[1;34m(url)\u001b[0m\n\u001b[0;32m      2\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mparse_fleet\u001b[0m\u001b[1;33m(\u001b[0m \u001b[0murl\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      3\u001b[0m     \u001b[0mheaders\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m{\u001b[0m\u001b[1;34m'user-agent'\u001b[0m\u001b[1;33m:\u001b[0m \u001b[1;34m'Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko'\u001b[0m\u001b[1;33m}\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 4\u001b[1;33m     \u001b[0mf\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mrequests\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0murl\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mheaders\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mheaders\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      5\u001b[0m     \u001b[0msoup\u001b[0m\u001b[1;33m=\u001b[0m \u001b[0mBeautifulSoup\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mtext\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m\"lxml\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      6\u001b[0m     \u001b[0mfleets\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mNameError\u001b[0m: name 'requests' is not defined"
     ]
    }
   ],
   "source": [
    "airlines={\"CSN\": 270, \"CES\":226, \"CCA\":212}\n",
    "for name, count in airlines.items():\n",
    "    for offset in range(0, count, 40):\n",
    "        # url: http://flightaware.com/live/fleet/CSN?;offset=0;order=ident;sort=ASC\n",
    "        url= \"http://flightaware.com/live/fleet/\"+name+\"?;offset=\"+str(offset)+\";order=ident;sort=ASC\"\n",
    "        fleets= parse_fleet(url)\n",
    "        save_fleet(fleets)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 完整代码\n",
    "import requests\n",
    "from bs4 import BeautifulSoup\n",
    "\n",
    "def parse_fleet( url):\n",
    "    headers = {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko'}\n",
    "    f = requests.get(url, headers=headers)\n",
    "    soup= BeautifulSoup(f.text, \"lxml\")\n",
    "    fleets=[]\n",
    "    fleets_rows= soup.select('table[class=\"prettyTable fullWidth\"] > tr')\n",
    "    #print(fleets_rows)\n",
    "    for row in fleets_rows:\n",
    "        try:\n",
    "            fields= row.select('a')\n",
    "            #print(fields)\n",
    "            if len(fields) == 3:\n",
    "                fleet_id= fields[0].text\n",
    "                airport_s= fields[1].text\n",
    "                airport_d= fields[2].text\n",
    "                airplane= \"\"\n",
    "            elif len(fields) == 4:\n",
    "                fleet_id= fields[0].text\n",
    "                airplane= fields[1].text\n",
    "                airport_s= fields[2].text\n",
    "                airport_d= fields[3].text\n",
    "\n",
    "            airline= fleet_id[:3]\n",
    "            if len(airport_s)==10 :\n",
    "                airport_s3= airport_s[:3]\n",
    "                airport_s4= airport_s[6:]\n",
    "            else:\n",
    "                airport_s3= airport_s4= airport_s\n",
    "\n",
    "            if len(airport_d)==10 :\n",
    "                airport_d3= airport_d[:3]\n",
    "                airport_d4= airport_d[6:]\n",
    "            else:\n",
    "                airport_d3= airport_d4= airport_d\n",
    "\n",
    "            fleet= {\n",
    "                        \"airline\": airline,\n",
    "                        \"id\" : fleet_id,\n",
    "                        \"airplane\" : airplane,\n",
    "                        \"airport_s3\" : airport_s3,\n",
    "                        \"airport_s4\" : airport_s4,\n",
    "                        \"airport_d3\" : airport_d3,\n",
    "                        \"airport_d4\" : airport_d4\n",
    "                    }\n",
    "            fleets.append(fleet)\n",
    "        except:\n",
    "            pass\n",
    "    \n",
    "    return fleets\n",
    "\n",
    "import mysql.connector\n",
    "def save_fleet(fleets):\n",
    "    try:\n",
    "        cnx = mysql.connector.connect(user='flightdata', password='flightdata',\n",
    "                                  host='127.0.0.1',\n",
    "                                  database='flightdata')\n",
    "        cursor = cnx.cursor()\n",
    "        cursor.execute(\"create table if not exists fleet(id varchar(50) primary key, airline varchar(10), \\\n",
    "                       airplane varchar(10),  airport_s3 varchar(10) ,airport_s4 varchar(10) , \\\n",
    "                      airport_d3 varchar(10) ,airport_d4 varchar(10));\")\n",
    "        add_fleet = \"INSERT ignore INTO fleet  \\\n",
    "                      (id, airline, airplane, airport_s3,airport_s4, airport_d3,airport_d4) \\\n",
    "                      VALUES (%s,%s,%s,%s,%s,%s,%s)\"\n",
    "        for f in fleets:\n",
    "            #print(f['id'])\n",
    "            cursor.execute(add_fleet, (f['id'], f['airline'],f['airplane'],f['airport_s3'],f['airport_s4'], \n",
    "                                       f['airport_d3'],f['airport_d4']))\n",
    "\n",
    "        cnx.commit()\n",
    "\n",
    "        cursor.close()\n",
    "        cnx.close()\n",
    "    except:\n",
    "        pass\n",
    "\n",
    "\n",
    "if __name__ == \"__main__\":\n",
    "    # 航线数据 https://flightaware.com/live/fleet/\n",
    "    airlines={\"CSN\": 270, \"CES\":226, \"CCA\":212}\n",
    "    for name, count in airlines.items():\n",
    "        for offset in range(0, count, 40):\n",
    "            # url: http://flightaware.com/live/fleet/CSN?;offset=0;order=ident;sort=ASC\n",
    "            url= \"http://flightaware.com/live/fleet/\"+name+\"?;offset=\"+str(offset)+\";order=ident;sort=ASC\"\n",
    "            print(url)\n",
    "            fleets= parse_fleet(url)\n",
    "            print( \"Get fleets: \"+ str(len(fleets)))\n",
    "            save_fleet(fleets)    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
